const webpack = require("webpack");
const path = require("path");
const CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");

const _date = new Date().getTime().toString();

module.exports = {
    module: {
        loaders: [{
                test: /\.jsx$|\.js$/,
                loader: "react-hot!babel-loader?presets[]=react,presets[]=es2015",
                include: path.join(__dirname, '/app/reactProject')
            },
            {
                test: /.(png|jpg)$/,
                loader: 'url-loader?limit=8192',
                include: path.join(__dirname, '/app/cssImg')

            },
            {
                test: /\.css$/,
                loaders: ["style", "css"],
                include: path.join(__dirname, '/app/css')

            }
        ]
    },
    entry: {
        app: [
            'webpack-dev-server/client?http://localhost:8000', // WebpackDevServer host and port
            'webpack/hot/dev-server', // "only" prevents reload on syntax errors
            "./app/reactProject/app.jsx"
        ],
        vendor: ["react", "react-dom", "react-router", "react-redux", 'react-fastclick', "redux", "iscroll", "islider.js", "jquery", "lodash", "react-iscroll", "immutable"]
    },
    output: {
        path: path.join(__dirname, '/app/bundle'),
        filename: "[name].bundle.js",
        publicPath: '/bundle/'
    },
    resolve: {
        /*alias: {
            appCommon: path.join(__dirname, '/app/reactProject/common'),
            appBase: path.join(__dirname, '/app/reactProject/base'),
            appContainers: path.join(__dirname, '/app/reactProject/containers/Home.jsx'),
            appModules: path.join(__dirname, '/app/reactProject/modules/HomeBigType.jsx')
        }*/
        // ,
        // extensions: ['', '.js', '.jsx']
    },
    compiler: {
        stats: {
            colors: true
        }
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new CommonsChunkPlugin({
            name: "vendor",
            minChunks: Infinity
        }),
    ],
    devtool: 'inline-source-map'
};